<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>登录</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
</head>

<style>
<<<<<<< HEAD
    * {
        margin: 0;
        padding: 0;
    }
</style>

<body>

    <!-- 定宽 -->
    <div id="left"></div>
    <!-- 自适应容器 -->
    <div id="right">
        <div id="inner"></div>
    </div>

    <style>

    </style>
    </style>
    <script>
var maxProfit = function (prices) {
    let dp = new Array(prices.length).fill(0);
    for (let i = 0; i <= prices.length - 2; i++) {
        // for (let j = i + 1; j <= prices.length - 1; j++) {
        //     dp[i] = Math.max(dp[i], prices[j] - prices[i])
        // }
        let maxInRest = prices.slice(i + 1).sort((a, b) => b - a)[0];
        dp[i] = maxInRest - prices[i];
    }
    console.log(dp)
    return dp.reduce((cur, next) => cur > next ? cur : next);
};
        console.log(maxProfit([7, 1, 5, 3, 6, 4]))
    </script>
=======
  body {
    /* width: 100px; */
    height: 5000px;
    background-color: red;
  }
</style>

<body>
  <script>
    var findPivotIndex = (nums, low, high) => {
      let temp = nums[low];
      while (low < high) {
        while (nums[high] >= temp && low < high) high--;
        arr[low] = arr[high]
        while (nums[low] < temp && low < high) low++;
        nums[high] = nums[low];
      }
      nums[low] = temp;
      return low;
    }
    var findKthLargest = function (nums, k) {
      let res;
      const quickSort = (nums, low, high) => {
        if (low <= high) {
          let pivot = findPivotIndex(nums, low, high);
          if (pivot === nums.length - k) {
            res = nums[pivot];
            return;
          }
          else if (pivot > nums.length - k) {
            quickSort(nums, low, pivot - 1);
          } else if (pivot < nums.length - k) {
            quickSort(nums, pivot + 1, high);
          }
        }
      }
      quickSort(nums, 0, nums.length - 1)
      return res;
    };

    let arr = [2, 1];
    // debugger;
    console.log(findKthLargest(arr, 2))
    console.log(arr)
  </script>
>>>>>>> 45ab3cadb6d16f435932953f86dc9898c90aa0c1
</body>


</html>